<template>
	<view class="mainbgc">
		<view class="toububjt">
			<view class="hui text_f">总收益</view>
			<view class="margin_top2 dbaitext">{{userInfo.total_commsion_price}}</view>
			<view class="flexbetween xiaobtext nav">
				<view class="hui text_f">团队人数：{{userInfo.team_num}}</view>
				<view class="hui text_f">累计获赠积分：{{userInfo.total_commsion_price}}</view>
			</view>
		</view>
		<!--  -->
		<view class="neirong">
			<view class="mainpadding ffffff radius  flexbetween">
				<view class="flexcolumn">
					<view class="hui">今日收益</view>
					<view class="text">{{userInfo.today_commsion_price}}</view>
				</view>
				<view class="flexcolumn">
					<view class="hui">昨日收益</view>
					<view class=" text">{{userInfo.yesterday_commsion_price}}</view>
				</view>
				<view class="flexcolumn">
					<view class="hui">本月收益</view>
					<view class=" text">{{userInfo.mouth_commsion_price}}</view>
				</view>
			</view>
			<view class="section">
				<view class="word_weight">团队成员</view>
				<view class="lan_img"></view>
			</view>
			<view class="mainpadding ffffff radius margin_top" v-for="item in list.data" :key="item.id">
				<view class="flexbetween margin_top xiahuax">
					<view class="flexbetween ">
						<view class="flexleft">
							<view class="image_ya">
								<image :src="item.avatar_text" mode=""></image>
							</view>
							<view class="center_zi">
								<view class="flexleft">
									<view class="name margin_right">
										<input type="text" v-model="item.usernnickname.nickname"
											@blur="changename(item,item.usernnickname.nickname)"
											v-if="item.usernnickname">
										<input type="text" v-model="item.nickname"
											@blur="changename(item,item.nickname)" v-else>
									</view>
									<u-icon name="edit-pen" color="#333" size="24"></u-icon>
								</view>
								<view class="hui num flexleft" @click="phone(item.mobile)">手机号：{{item.mobile}}<u-icon
										name="phone" color="#333" size="24"></u-icon></view>
								<view class="hui num">{{item.rec_time_text}}</view>
							</view>
						</view>
					</view>
				</view>
				<view class="flexbetween section_one margin_top">
					<view class="">邀请人数：<text class="red">{{item.user_num}}</text></view>
					<view class="">贡献积分：<text class="red">{{item.order_score}}</text></view>
				</view>
			</view>
		</view>
		<view class="gudingdb">
			<view class="bigbtn" @click="yaoqing">邀请好友</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},

		onLoad() {
			this.getinfo()
			this.init()
		},
		onShow() {

		},
		methods: {
			// 修改昵称
			changename(item, name) {
				httpRequest.request('/api/user/editTeamUserNickname', 'POST', {
					user_id: item.id,
					nickname: name
				}, false, false, true).then(res => {}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/user/myTeam', 'POST', {
					page: page || 1,
					limit: _this.limit,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}

				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			},
			getinfo() {
				httpRequest.request('/api/user/index', 'POST', {}, false, false, true).then(res => {
					if (res.code == 1) {
						this.userInfo = res.data
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			yaoqing() {
				uni.navigateTo({
					url: '/pages/mypage/yaoqinghaoyou'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.text_f {
		color: #ffffff;
	}

	.image_ya {
		width: 77rpx;
		height: 77rpx;
		border-radius: 50%;

		image {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
	}

	.footer {
		padding: 0rpx 20rpx;
	}

	// .query{
	// 		background-color: #3298fe;
	// 		padding: 20rpx 0rpx 20rpx 0rpx;
	// 		position: fixed;
	// 		bottom: 54rpx;
	// 		border-radius: 69rpx  69rpx  69rpx  69rpx;
	// 		font-size: 32rpx;
	// 		font-weight: 500;
	// 		color: #FFFFFF;
	// 	    width: 100%;
	// 		// margin: 0rpx 20rpx;
	// 		box-sizing: border-box;
	// 	}
	.lan_img {
		position: relative;
		bottom: 10rpx;
	}

	.num {
		padding-top: 5rpx;
	}

	.nav {
		margin-right: 100rpx;
	}

	.section {
		margin-top: 20rpx;
	}

	.section_one {
		padding: 20rpx 20rpx;
		background-color: RGBA(241, 241, 241, 1);
		font-size: 24rpx;
		font-weight: 500;
		color: #000000;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.red {
		color: rgba(255, 0, 0, 1);
	}

	.text {
		height: 41rpx;
		font-size: 34rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: #000000;
		padding-top: 20rpx;
	}

	.quxiaobtn {
		border-radius: 0 0 0 20rpx;
		width: 291.5rpx;
		height: 74rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fff;
		border-top: 1rpx solid #E7E7E7;
		border-right: 1rpx solid #E7E7E7;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.tanchuceng {
		padding: 40rpx 70rpx;
	}

	.neirong {
		width: 100%;
		position: absolute;
		box-sizing: border-box;
		top: 260rpx;
		padding: 0rpx 30rpx;
		padding-bottom: 150rpx;
	}

	// .btn {
	// 		width:100%;
	// 		// position: absolute;
	// 		box-sizing: border-box;
	// 		// top: 260rpx;
	// 		margin: 0rpx 30rpx;
	// 	}

	.dbaitext {
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
	}

	.xiaobtext {
		font-size: 32rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
		padding-top: 30rpx;
	}

	.toububjt {
		background-size: 100% 100%;
		width: 100%;
		padding: 20rpx 30rpx 0;
		height: 308rpx;
		box-sizing: border-box;
		background-color: #2992fe;
	}

	// 
	.item_image_box {
		width: 25%;
	}

	.content {
		padding: 30rpx 25rpx 0rpx 25rpx;
	}

	.search {
		width: 27rpx;
		height: 27rpx;
	}

	.supply_xq {
		padding: 9rpx 35rpx 10rpx 35rpx;
		background: RGBA(239, 239, 239, 1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333;
	}

	.ss {
		background-color: #f3f3f3;
		border-radius: 60rpx 60rpx 60rpx 60rpx;
		padding: 18rpx 20rpx 18rpx 60rpx;
	}

	.inp {
		background-color: #f3f3f3;
		width: 500rpx;
		padding: 0rpx 0rpx 0rpx 30rpx;
	}

	input:input-placeholder {
		font-size: 28rpx;
	}

	// 
	.name {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.center_zi {
		padding: 0rpx 20rpx;
	}

	.hei {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		margin: 20rpx 0rpx;
	}

	.center_shuju {
		width: 400rpx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
</style>